package main

import (
	"encoding/json"
	"fmt"
	"gozero/common"
)

type registerReq struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

func register() {
	data, _ := json.Marshal(registerReq{
		Username: "lxy1",
		Password: "123",
	})
	fmt.Println(string(data))
	resp, err := common.PostUrl("http://192.168.1.69:8888/v1/user/register", string(data))
	if err != nil {
		panic(err)
	}
	fmt.Print(resp)
}

func login() {
	data, _ := json.Marshal(registerReq{
		Username: "lxy1",
		Password: "123",
	})
	fmt.Println(string(data))
	resp, err := common.PostUrl("http://192.168.1.69:8888/v1/user/login", string(data))
	if err != nil {
		panic(err)
	}
	fmt.Print(resp)
}

func getInfo() {
	token := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzE1Mjk01TgsImlhdCI6MTczMTQ0MzA5OCwidXNlcklkIjoyfQ.6ipxVCenkCoI--f934FVpzpzLLTeOQVg-Vi0iVJt82U"
	resp, err := common.GetUrl("http://192.168.1.69:8888/v1/user/info", token)
	if err != nil {
		panic(err)
	}
	fmt.Print(resp)
}

func main() {
	getInfo()
}
